package com.example.amusic.service.v2

import android.content.ComponentName
import android.content.Context
import android.provider.MediaStore.Audio.Media
import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
import androidx.media3.common.Player
import androidx.media3.session.MediaController
import androidx.media3.session.SessionToken
import com.example.amusic.service.MusicService
import com.google.common.util.concurrent.ListenableFuture


private fun Context.MediaController(listener:MediaController.Listener) =
    MediaController.Builder(this, SessionToken(this,ComponentName(this, MusicService::class.java))).setListener(listener).buildAsync()

//val sessionToken = SessionToken(this, ComponentName(this, MusicService::class.java))
//val mediaControllerFuture = MediaController.Builder(this, sessionToken).buildAsync()
//mediaControllerFuture.addListener({
//    val player = mediaControllerFuture.get()
////            PlayServiceModule.setPlayer(player)
////            MyApp.playerController = PlayServiceModule.initPlayController()
//}, MoreExecutors.directExecutor())

//class RemoteImpl(
//    val context: Context
//) :Remote {
//
//    private var mediaController:ListenableFuture<MediaController> =context.MediaController()
//    override val position: Long
//        get() = TODO("Not yet implemented")
//    override val duration: Long
//        get() = TODO("Not yet implemented")
//    override val isPlaying: Boolean
//        get() = TODO("Not yet implemented")
//    override val playWhenReady: Boolean
//        get() = TODO("Not yet implemented")
//    override val meta: MediaMetadata?
//        get() = TODO("Not yet implemented")
//    override val current: MediaItem?
//        get() = TODO("Not yet implemented")
//    override val player: Player?
//        get() = TODO("Not yet implemented")
//
//    override fun play(playWhenReady: Boolean) {
//        TODO("Not yet implemented")
//    }
//
//    override fun pause() {
//        TODO("Not yet implemented")
//    }
//
//    override fun togglePlay() {
//        TODO("Not yet implemented")
//    }
//
//    override fun skipToNext() {
//        TODO("Not yet implemented")
//    }
//
//    override fun skipToPrev() {
//        TODO("Not yet implemented")
//    }
//}